#include<iostream>
#include<cstring>
#include<bitset>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int a[N];
int n;
bitset<N>s;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	s[1] = 1;
	for (int i = 1; i <= n; i++) {
		s |= (s >> i) << (a[i] + i);
	}
	for (int i = 0; i < 20; i++) {
		cout << s[i];
	}
	cout << endl;
	LL ans = 0;
	LL sum = 0;
	for (int i = 1; i < N; i++) {
		if (i <= n)sum += a[i];
		if (s[i]) ans = max(ans, sum - (i - 1));
	}
	cout << ans << endl;
	return 0;
}